<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title><?=$da['title']?></title>
<link rel="stylesheet" type="text/css" href="mode/weui/weui.min.css"/>
<link rel="stylesheet" type="text/css" href="web/res/fontawesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="webmain/css/rui.css">
<link rel="shortcut icon" href="favicon.ico" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="js/jswx.js"></script>
<script type="text/javascript" src="js/base64-min.js"></script>
<style>
html,body{overflow:hidden;background-color:#fbf9fe}
.weui_tabbar_icon{text-align:center;color:#888888;font-size:20px;}
.weui_tabbar_item{padding-top:2px;margin-bottom:5px;position:relative}
.weui_media_box{padding:10px 15px}
.weui_media_box.weui_media_appmsg .weui_media_hd {height:40px;width:40px;line-height:40px}
.weui_media_box .weui_media_desc{height:20px;line-height:20px;padding-right:20px}
.weui_bar_item_on .weui_tabbar_icon{color:#1389D3}
.weui_grid_icon{width:26px;height:26px;text-align:center;}
.weui_grid_icon img{border-radius:6px}
.weui_grid_icon i{font-size:26px}
.weui_grid_icon span{position:absolute;top:5px;right:5px;}
.weui_tabbar_item span{position:absolute;right:5px;top:2px}
.weui_media_bd span{position:absolute;right:10px;top:20px}
.weui_media_bd font{position:absolute;right:5px;top:45px;font-size:13px;color:#888888}
.hd{padding:2em 0; text-align:center}
.hd img{height:100px;width:100px;border-radius:50px}
.weui_tabbar{position:fixed}

@keyframes fadein{0%{opacity:0}100%{opacity:1;}}
.fadein{-webkit-animation:fadein 1s;-moz-animation:fadein 1s}

.weui_media_box:before{left:0}
.yingshright{position:absolute;right:0px;bottom:0px;display:block; width: 0;height: 0;border-bottom: 15px solid #dedede;border-left: 15px solid transparent;}
.agentp{color:#888888;padding:5px;font-size:14px;margin-top:5px}
.weui_daohang{display:inline-block;width:100%;background:#f1f1f1;}
.weui_daohang span{height:50px;padding:0px 8px;display:block;line-height:50px; float:left;margin:0px;}
.weui_daohang .jiantou{padding:0px;font-size:12px;color:#cccccc}
.weui_grid_label{height:20px;overflow:hidden}
.fenqu{width: 100%;float: left;margin-left:10px;margin-top: 10px;  border-bottom:1px solid 	#DCDCDC;}
.wode{font-size: 14px;margin-top: 18px;}
</style>
<?php
//if($web=='ding')echo '<script type="text/javascript" src="js/jsdd.js?'.time().'"></script>';
?>

<script>
var grouparr = [],userarr=[];

function initbody(){

	date=js.now();
	im.init();
	//if(js.jssdkdingding)js.jssdkdingding();
	adminface = js.getoption('adminface','images/noface.png');
	adminame = js.getoption('adminame','我的');
	if(adminface)get('myface').src=adminface;
	$('#myname').html(adminame);
	$('#myshow_name').html(adminame);
	$('#myshow_id').html(js.getoption('adminid'));
	$('#myshow_deptname').html(js.getoption('deptallname'));
	$('#myshow_ranking').html(js.getoption('ranking'));

	im.touchobj = $('#mainbody').rockdoupull({
		downbool:true,
		ondownsuccess:function(){
			im.reload('none');
		},
		ondownbefore:function(){
			return (im.index==0 || im.index==1 || im.index==2);
		},
		ondrayrlend:function(lx){
			if(lx<-100)im.changetab(im.index+1);
			if(lx>100)im.changetab(im.index-1);
		}
	});

	try{
	var site = sessionStorage.getItem('nowtabs');
	if(!site)site=0; //修改默认显示哪个选择卡
	var url = location.href;
	if(url.indexOf('#list')>0)site=0;
	if(url.indexOf('#ying')>0)site=1;
	if(url.indexOf('#user')>0)site=2;
	im.changetab(site);
	}catch(e){}
	var errmsg = js.request('errmsg');
	if(!isempt(errmsg)){
		js.wx.alert(jm.base64decode(errmsg));
	}
}
var agentarr={};
var im={
	index:0,
	changetabci:0,
	changetab:function(lx){
	
			lx	= parseFloat(lx);
			if(lx<0)lx=4;
		if(lx>4)lx=0;
		$("[index='main']").hide();
		var sid = 'main_index'+lx+'';
		if(sid=='main_index2'){
			$('#mainbody_show').show();
		}
		$('#'+sid+'').show();
		$('.weui_tabbar a').removeClass('weui_bar_item_on');
		$('.weui_tabbar a:eq('+lx+')').addClass('weui_bar_item_on');
		// var tass=['<?=$da['title']?>','办公','联系人',adminame];
		//定义title
		var tass=['消息','办公','云盘','联系人','我的'];
		$('.r-header-text').html(tass[lx]);
		this.index = lx;
		try{sessionStorage.setItem('nowtabs', lx);}catch(e){}
		im.touchobj.hidescrolls();
	
		//新增云盘定义cloud
		if(lx==2){
	
			//  this.showcloud();
		}
		if(lx==3){
			this.showuserlist();
		}
		if(lx==4){
	
			this.showmyinfo();
			
		}else{
			setTimeout('im.showmyinfo()',200);
		}
		this.changetabci++;
	},
	getheight:function(ss){
		var hei = 0;if(!ss)ss=0;
		if(get('header_title'))hei+=50;
		if(get('footerdiv'))hei+=55;
		return $(window).height()-hei+ss;
	},
	resiezess:function(){
		var hei = im.getheight();
		$('#mainbody').css('height',''+hei+'px');
		if(im.touchobj)im.touchobj.resize();
	},
	init:function(){
		this.resiezess();
		$(window).resize(im.resiezess);
		var agentjson 	= js.getoption('agentjson');
		
		var hisjson 	= js.getoption('historyjson');
		if(agentjson=='' || hisjson==''){
			this.reload();
		}else{
		
			this.reload();
			var str = js.getoption('silderarr');
			if(str)this.showsilder(js.decode(str));
			im.showagent(js.decode(agentjson));
			im.showhistory(js.decode(hisjson));
		}
		this.initsearch();
		$('#nowcompany_div').html(js.getoption('nowcompany'));
	},
	qihuendrap:function(yd){
		if(yd>100 && this.index>0)this.changetab(this.index-1);
		if(yd<-100 && this.index!=3)this.changetab(this.index+1);
	},
	reloadss:function(lx){
		js.ajax('indexreim','mwebinit',false,function(ret){

			im.reloadshow(ret);
		}, lx, false, function(){
			im.showerror();
		});
	},
	splittime:5,
	reloadshow:function(ret){
		this.loadtime = ret.loadtime;
		js.setoption('agentjson', ret.agentjson);
		js.setoption('historyjson', ret.historyjson);
		var yyda = js.decode(ret.agentjson);
		im.showcompanyinfo(ret.companyinfo);
		im.showagent(yyda);
		//显示云盘
		im.showcloud(yyda);
	
		im.showhistory(js.decode(ret.historyjson));
		js.setoption('myhomenum', ret.myhomenum);
		if(ret.silderarr){
			var str = '';
			if(ret.silderarr.length>0)str=JSON.stringify(ret.silderarr);
			js.setoption('silderarr', str);
			this.showsilder(ret.silderarr);
		}
		im.showhomeagent(yyda);
		im.reloadok();
		if(ret.editpass==0){
			js.wx.alert('请先修改密码后在使用', function(){
				im.editpass();
			});
		}else{
			this.timeajaxs();
		}
	},
	timeajaxs:function(){
		clearTimeout(this.homeretime);
		if(this.loadtime)this.homeretime=setTimeout(function(){im.timeajax()},this.splittime*1000);
	},
	timeajax:function(){
		js.ajax('indexreim','loadhit', {time:this.loadtime}, function(ret){
			im.loadtime = ret.loadtime;
			if(ret.rows.length>0){
				im.shownewhistory(ret.rows);
			}
			im.timeajaxs();
		},'none',false, function(){
			js.msg();
			im.timeajaxs();
		},'get');
	},
	shownewhistory:function(a){
		var i,len=a.length,d=false;
		for(i=0;i<len;i++){
			if(!d && a[i].stotal>0)d=a[i];
			this.showhistorys(a[i], true);
		}
		this.changestotl(false,0);
		if(i>0)$('#historylist_tems').hide();
	},
	showcompanyinfo:function(info){
		if(info){
			this.companyinfo = info;
			var neme= info.name;
			js.setoption('nowcompany', neme);
			$('#nowcompany_div').html(neme);
		}
	},
	showsilder:function(a){
		if(this.showsilderobj)this.showsilderobj.remove();
		if(!a || a.length==0)return;
		this.showsilderobj = $.rocksilder({
			view:'home_silder',
			titlebool:true,
			data:a,
			onclick:function(d){
				js.location(d.url);
			}
		});
	},
	showerror:function(){
		if(this.touchobj)this.touchobj.ondownerror();
	},
	reloadok:function(){
		if(this.touchobj)this.touchobj.ondownok();
	},
	reload:function(lx){
		if(this.index==2){
			this.reloaduser(lx);
		}else{
		
			this.reloadss(lx);
		}
	},
	showhomeagent:function(d){
		var stotal=0;
		var myhomenum = js.getoption('myhomenum');
		$('#home_yinglistdiv').hide();
		$('#home_yinglist').html('');
		if(!myhomenum)return;
		myhomenum = ','+myhomenum+',';
		var bo = false;
		for(var i=0;i<d.length;i++){
			stotal+=parseFloat(d[i].stotal);
			if(myhomenum.indexOf(','+d[i].num+',')>-1){
				this.showagents(d[i], 'home_yinglist', 'histotal_home_');
				bo = true;
			}
		}
		if(bo)$('#home_yinglistdiv').show();
		this.changestotl(false,0);
	},
	showagent:function(a){
		var i,len=a.length,d,oshow,typearr={},s,ois=0;
		oshow = $('#main_index1');
		oshow.html('');
		for(i=0;i<len;i++){
			d 	= a[i];
			d.i = i;
		
			//如果不是云盘就显示多加了一个if
		if(d.iscloud==0){
			if(!typearr[d.types])typearr[d.types]=[];
					typearr[d.types].push(d);
		}
	
		}
	
		for(ty in typearr){
	
			ois++;
			len = typearr[ty].length;
		
			s = '<div class="agentp">'+ty+'</div><div id="agentshow_'+ois+'" style="background-color:white" class="weui_grids"></div>';
			oshow.append(s);
			for(i=0;i<len;i++){
				this.showagents(typearr[ty][i], 'agentshow_'+ois+'');
			}
		}
		this.changestotl('agentstotal_',1);
	},

//新增云盘函数
showcloud:function(a){
		var i,len=a.length,d,oshow,typearr={},s;
		oshow = $('#main_index2');
	
		oshow.html('');
		for(i=0;i<len;i++){
			d 	= a[i];
			d.i = i;
		
		//如果是云盘就显示多加了一个if
		if(d.iscloud==1){
			if(!typearr[d.types])typearr[d.types]=[];
					typearr[d.types].push(d);
		}
	
		}

		for(ty in typearr){
		
			len = typearr[ty].length;
		
			s = '<div id="agentshow" style="background-color:white" class="weui_grids"></div>';
			oshow.append(s);
			for(i=0;i<len;i++){
				this.showfenqus(typearr[ty][i], 'agentshow');
			}

		//分割线
		this.showareas('agentshow');
		//获取分区

		//用户id
		this.getareas();

		}

		 this.changestotl('agentstotal_',1);
	},
	//分界线
	showareas:function(shows){
		var s='';
		s+='<hr>';
		$('#'+shows+'').append(s);
	},
	//无数据
	noareas:function(shows){
		var s='';
		s+='<p style="color:red,font-size:12px;">还没有创建分区哦!</p>';
		$('#'+shows+'').append(s);
	},
//获取分区函数
getareas:function(shows){
	var url = '?m=ying&d=we&num=word&ac=1';
	$.ajax({ 
            async:false,
            url: url,
            type: "GET",
            dataType: "json",
            success: function(result){
               var d=result;
			   var data=d.rows;
		
	if(data){
		var len=data.length;
		//循环数据
		// for(i=0;i<len;i++){
		// 		im.showcloudareas(data[i],'agentshow',i);
		// 	}
		im.showdata(d);
	}else{
//无数据
		im.noareas('agentshow');
	}
            },error:function(){
				js.msg('获取数据出错');
            }
        });
	},

	showdata:function(a){
		$('#wordlisttable').remove();
		var rows = a.rows;
		var i,len=rows.length,s;
	
		s='<table id="wordlisttable" style="width:100%; background-color:white;font-size:14px">';
		for(i=0;i<len;i++){
			s+=im.showfqlist(rows[i],i);
		}
	    s+='</table>';
		s+='<div style="margin-top:10px;display:none"  class="showblank" id="showblank">共'+len+'条记录';
		if(a.maxpage>1)s+=',当前'+a.maxpage+'/'+a.page+'页';
		if(a.page<a.maxpage){
			s+=', <a id="showblankss" onclick="im.nextpage(this)" href="javascript:;">点击加载</a>';
		}
		s+='</div>';

	
		// $('#'+shows+'').append(s);


		if(a.page<=1){
			$('#mainbody_show').html(s);
		}else{
			$('#mainbody_show').append(s);
		}
	},
	showfqlist:function(d,i){

		if(!d.id)d.id=d.fileid;
		if(!d.fileext)d.fileext='folder';
		var oi = i;
		var s1='';
		var s='';
		s+='<tr style="height:60px;border-top:1px #f1f1f1 solid" id="'+d.fileext+'_'+d.id+'" onclick="im.openfenqu('+d.id+')" >';
		s1='<div id="filename_'+oi+'">'+d.name+'</div>';
		if(d.fileid){
			s1+='<div style="font-size:12px;color:#888888">大小：'+d.filesizecn+'';
			if(!isempt(d.shate))s1+='，共享给：'+d.shate+'';
			s1+='</div>';
		}
		if(d.fileext=='folder'){
			s+='<td align="center" width="40"><img src="images/folder.png" height="24" width="24"></td><td>'+s1+'</td>';
		}else{
			var slx = d.fileext;
			if(js.fileall.indexOf(','+slx+',')<0)slx='wz';
			var fstr = 'web/images/fileicons/'+slx+'.gif';
			if(d.thumbpath)fstr = d.thumbpath;
			s+='<td align="center" width="40"><img src="'+fstr+'" height="16" width="16"></td><td>'+s1+'</td>';
		}
		s+='</tr>';
		return s;
	},

	//拼接分区
	showcloudareas:function(d,shows,i){
		if(!d.id)d.id=d.fileid;
		if(!d.fileext)d.fileext='folder';
		 var oi = i;
		var s1='';
		var s='';
		s+='<tr style="height:60px;border-top:1px #f1f1f1 solid" id="'+d.fileext+'_'+d.id+'" onclick="im.openfenqu('+d.id+')" >';
		s1='<div id="filename_'+d.id+'">'+d.name+'</div>';
		if(d.fileid){
			s1+='<div style="font-size:12px;color:#888888">大小：'+d.filesizecn+'';
			if(!isempt(d.shate))s1+='，共享给：'+d.shate+'';
			s1+='</div>';
		}
		if(d.fileext=='folder'){
			s+='<td align="center" width="40"><img src="images/folder.png" height="24" width="24"></td><td>'+s1+'</td>';
		}else{
			var slx = d.fileext;
			if(js.fileall.indexOf(','+slx+',')<0)slx='wz';
			var fstr = 'web/images/fileicons/'+slx+'.gif';
			if(d.thumbpath)fstr = d.thumbpath;
			s+='<td align="center" width="40"><img src="'+fstr+'" height="16" width="16"></td><td>'+s1+'</td>';
		}
		s+='</tr>';
		agentarr[d.id]=d;
		$('#'+shows+'').append(s);
	},
	//切换分区
	changfenqu:function(id){
		// yy.sousoukey='';
		// yy.sqxs();
		// $('#workheader span:gt(0)').remove();
		// this.uptype = $(fq.options[fq.selectedIndex]).attr('uptype');
		this.getfile(0, id);
	},
	disabedgl:function(lx){
		var clas = 'weui_navbar_item_disabled';
		if(lx){
			$('div[tempxu=0]').addClass(clas);
			$('div[tempxu=2]').addClass(clas);
		}else{
			$('div[tempxu=0]').removeClass(clas);
			$('div[tempxu=2]').removeClass(clas);
		}
	},
	// 打开分区
	getfile:function(pid,cid,alx,padg){
		this.typeid = pid;
		this.cqid = cid;

		// this.disabedgl(true);
		if(!alx)alx='';
		this.atype = alx;
		if(!padg)padg=1;
		this.page = padg;
		var cqids=cid;
		var key='';

		
		// get('cpselect').value = this.cqid;
		js.ajax('word','getdata',{typeid:pid,cqid:this.cqid,cqids:cqids,atype:alx,page:padg,key:key},function(a){
			// console.log(a);
			ismanage = a.ismanage;
			if(a.ismanage==1)im.disabedgl(false);//有权限
			im.data=[];
			im.showdata(a,'wordlisttable');
		},'mode');
	},

//打开文件夹
clicksse:function(id,e,o1){

		this.chentcolor(oi,e,o1);
		var d = this.data[oi-1];
		this.tempoi = oi;
		this.tempda = d;
		var a = [{name:(d.fileext=='folder')?'打开':'下载',lx:0}];
		if(d.fileext!='folder'){
			a.push({name:'预览',lx:7});
		}
		if(this.ismanage==1){
			a.push({name:'重命名',lx:1});
			a.push({name:'删除',lx:4});
			a.push({name:'共享给...',lx:5});
			a.push({name:'移动',lx:2});
		}
		if(d.fileext!='folder'){
			a.push({name:'转发给...',lx:6});
		}
		js.showmenu({data:a,onclick:function(d){c.clickmenuss(d)}});
	},
//打开文件夹2
	openfenqu:function(id){
		 if(!id)return;
		var url = '?m=ying&d=we&num=word&fqid='+id;
		js.location(url);
	},

	showfenqus:function(d,shows,qizx){
		var s='';
		if(!qizx)qizx='agentstotal_';
		var s1=d.stotal;if(s1==0)s1='';
		var ac=d.num;

		s='<a href="javascript:;" onclick="im.reopenagent('+d.id+',\''+ac+'\')" class="weui_grid ">';
		s+='<div class="weui_grid_icon">';
			s+='	<img src="'+d.face+'">';
		s+='	<span id="'+qizx+''+d.id+'" temp="agent'+d.id+'" class="badge">'+s1+'</span>';
		s+='</div>';
		s+='<p class="weui_grid_label">';
		s+=' '+d.name+'';
		s+='</p>';
		s+='</a>';
		agentarr[d.id]=d;
		$('#'+shows+'').append(s);

	},
	reopenagent:function(id,ac){
		if(ac=='word'){
			this.reload();
		}else{
			var d=agentarr[id],a=[],i,d1,d2,s2;
		
if(!d)return;
var url = '?m=ying&d=we&num='+d.num+'';

if(d.url=='link' && !isempt(d.urlm))url=d.urlm;
//$('#agentstotal_'+id+'').html('');
$('span[temp="agent'+id+'"]').html('');
this.changestotl('agentstotal_',1);
this.changestotl(false,0);
js.location(url);
		}
},
	showagents:function(d,shows,qizx){
		var s='';
		if(!qizx)qizx='agentstotal_';
		var s1=d.stotal;if(s1==0)s1='';
		s='<a href="javascript:;" onclick="im.openagent('+d.id+')" class="weui_grid ">';
		s+='<div class="weui_grid_icon">';
			s+='	<img src="'+d.face+'">';
		s+='	<span id="'+qizx+''+d.id+'" temp="agent'+d.id+'" class="badge">'+s1+'</span>';
		s+='</div>';
		s+='<p class="weui_grid_label">';
		s+=' '+d.name+'';
		s+='</p>';
		s+='</a>';
		agentarr[d.id]=d;
		$('#'+shows+'').append(s);

	},
	changestotl:function(jg,lx){
		if(!jg)jg='histotal_';
		var o=$("span[id^='"+jg+"']"),oi=0,i,len=o.length,v1;
		for(i=0;i<len;i++){
			v1=$(o[i]).text();
			if(v1=='')v1='0';
			oi=oi+parseFloat(v1);
		}
		if(oi==0)oi='';
		$('#stotal_ss'+lx+'').html(''+oi);
	},
	openagent:function(id){
	
			var d=agentarr[id],a=[],i,d1,d2,s2;
		if(!d)return;
		var url = '?m=ying&d=we&num='+d.num+'';

		if(d.url=='link' && !isempt(d.urlm))url=d.urlm;
		//$('#agentstotal_'+id+'').html('');
		$('span[temp="agent'+id+'"]').html('');
		this.changestotl('agentstotal_',1);
		this.changestotl(false,0);
		js.location(url);
		
	},
	showhistorydata:{},
	showhistory:function(a){
		var i,len=a.length;
		$('#historylist').html('');
		$('#historylist_tems').show();
		for(i=0;i<len;i++){
			this.showhistorys(a[i]);
		}
		this.changestotl(false,0);
		if(i>0)$('#historylist_tems').hide();
	},
	showhistorys:function(d,pad){
		var s,ty,o=$('#historylist'),d1,st,attr;
		var num = ''+d.type+'_'+d.receid+'';
		$('#index_'+num+'').remove();
		this.showhistorydata[num]=d;
		st	= d.stotal;if(st=='0')st='';
		var ops = d.optdt.substr(11,5);
		if(d.optdt.indexOf(date)!=0)ops=d.optdt.substr(5,5);
		ty	= d.type;
		s='<a id="index_'+num+'" onclick="im.clickitems(\''+ty+'\','+d.receid+', this)" class="weui_media_box weui_media_appmsg">';
		s+='	<div class="weui_media_hd">';
		s+='		<img class="weui_media_appmsg_thumb" src="'+d.face+'">';
		s+='	</div>';
		s+='	<div class="weui_media_bd">';
		s+='		<span id="histotal_'+num+'" class="badge">'+st+'</span>';
		s+='		<font >'+ops+'</font>';

		s+='		<h4 class="weui_media_title">'+d.name+'</h4>';
		s+='		<p class="weui_media_desc">'+jm.base64decode(d.cont)+'</p>';
		s+='	</div>';
		s+='</a>';
		if(!pad){
			o.append(s);
		}else{
			o.prepend(s);
		}
	},
	clickitems:function(ty,id,o){
		var o1=$(o),num=''+ty+'_'+id+'',d=this.showhistorydata[num];
		var da = [{name:'打开',lx:0}];
		if(d && d.stotal>0)da.push({name:'标识已读',lx:2});
		da.push({name:'删除此记录',lx:1});
		js.showmenu({
			data:da,
			onclick:function(a){
				var lx=a.lx;
				if(lx==0){
					im.openguser(ty,id);
				}
				if(lx==1){
					o1.remove();
					var tst=$('#historylist').text();if(tst=='')$('#historylist_tems').show();
					js.ajax('reim','delhistory',{type:ty,gid:id},false,'none');
				}
				if(lx==2){
					im.biaoyidu(ty,id, true);
				}
			}
		});
	},
	openuinfo:function(id){
		js.location('?a=userinfo&d=we&uid='+id+'');
	},
	biaoyidu:function(ty,id,lbo){
		if(lbo){
			var num = ''+ty+'_'+id+'';
			$('#histotal_'+num+'').html('');
			this.changestotl(false,0);
			var d = this.showhistorydata[num];
			if(d)d.stotal = '0';
		}
		js.ajax('reim','yiduall',{type:ty,gid:id},false,'none');
	},
	openguser:function(ty,id){
		var num = ''+ty+'_'+id+'';
		$('#histotal_'+num+'').html('');
		this.changestotl(false,0);
		if(ty=='agent'){
			var d = this.showhistorydata[num];
			var url='';
			if(d && d.stotal>0 && !isempt(d.xgurl)){
				d.stotal = '0';
				var xga = d.xgurl.split('|');
				if(xga[1]>0)url='task.php?a=x&num='+xga[0]+'&mid='+xga[1]+'';
			}
			if(!url){
				this.openagent(id);
			}else{
				this.biaoyidu(ty,id,false);
				js.location(url);
			}
		}else{
			js.location('?m=chat&d=we&type='+ty+'&uid='+id+'');
		}
	},
	loginout:function(){
		js.wx.confirm('确定要退出系统吗？',function(lx){
			if(lx=='yes')im.loginouts();
		});
	},
	loginouts:function(){
		js.ajax('login','loginexit',false,function(){
			js.wx.msgok('已成功退出',function(){
				js.location('?m=login&d=we');
			},1);
		});
	},
	showmenu:function(){
		js.wx.actionsheet({
			data:[{
				name:'<img src="'+adminface+'" align="absmiddle" height="30" width="30"> '+adminame+'',lx:0
			},{
				name:'刷新数据',lx:1
			},{
				name:'修改密码',lx:2
			},{
				name:'退出登录',lx:3
			}],
			onclick:function(a){
				var lx=a.lx;
				if(lx==0)im.changetab(4);
				if(lx==1)im.reload();
				if(lx==2)im.editpass();
				if(lx==3)im.loginout();
			}
		});
	},
	editpass:function(){
		js.location('?m=index&d=we&a=editpass');
	},
	jiami:function(){
		var url=js.getajaxurl('getsesfileurl','mode_worc|input','flow');
		$.ajax({
		type: "post",
		dataType: "json",
		url:url,
		success: function (data) {
		js.location(data.data.data);
		}
		});
	},
	changeuser:function(lx){
		$("#userlx div").removeClass('active');
		$("#userlx_"+lx+"").addClass('active');
		$("div[temp='user']").hide();
		$("div[temp='user']:eq("+lx+")").show();
	},
	showuserlist:function(){
		var us = js.getoption('userjson');
		if(us==''){
			this.reloaduser();
		}else{
			userarr=js.decode(us);
			grouparr=js.decode(js.getoption('groupjson'));
			deptarr=js.decode(js.getoption('deptjson'));
			im.showuserall();
			im.showgroupall();
		}
	},
	reloaduser:function(lx){
		js.ajax('dept','data',false,function(ret){
			js.setoption('deptjson', ret.deptjson);
			js.setoption('userjson', ret.userjson);
			js.setoption('groupjson', ret.groupjson);
			deptarr=js.decode(ret.deptjson);
			userarr=js.decode(ret.userjson);
			grouparr=js.decode(ret.groupjson);
			im.showuserall();
			im.showgroupall();
			im.reloadok();
		}, lx, false, function(){
			im.showerror();
		});
	},
	showuserall:function(){
		var i,len=userarr.length;
		$('#userdao').html('');
		$('#userstotal').html('('+len+')');
		this.showuserlists(deptarr[0].id, 0);
	},
	showuserlists:function(id,level, o1){
		if(o1){
			var as = $('#userdao span');
			var rb = false;
			for(var i=0;i<as.length;i++){
				if(o1==as[i])rb=true;
				if(rb)$(as[i]).remove();

			}
		}
		var a =deptarr,i,len=a.length,d,dn;
		$('#deptlist').html('');
		$('#list').html('')

		for(i=0;i<len;i++){
			d = a[i];
			if(d.id==id)dn=d;
			if(d.pid==id){
				d.face = 'images/wjj.png';
				this.showdeptlsit(d, level+1);
			}
		}
		if(level>0)$('#userdao').append('<span class="jiantou">＞</span>');
		$('#userdao').append('<span onclick="im.showuserlists('+id+',0, this)">'+dn.name+'</span>');
		len=userarr.length;

		//人员放在前面
		var noi = 0;
		for(i=0;i<len;i++){
			d = userarr[i];
			if(d.deptid==id || d.deptidss.indexOf(','+id+',')>-1){
				this.showlist(d, false);
				noi++;
			}
		}

		if(noi==0 && $('#deptlist').html()==''){
			$('#list').append('<div style="font-size:14px;text-align:center;padding:30px 10px;color:#cccccc">'+dn.name+' 下无联系人</div>');
		}
	},
	showdeptlsit:function(a, level){
		var s='';
		s+='<a class="weui_media_box weui_media_appmsg" onclick="im.showuserlists('+a.id+','+level+')">';
		s+=' 	<div class="weui_cell_hd"><img src="'+a.face+'" alt="" style="width:34px;margin-right:5px;display:block"></div>';
		s+=' 	<div class="weui_cell_bd weui_cell_primary"><p>'+a.name+'';
		if(a.ntotal>0)s+=' <span style="font-size:12px;color:#888888">('+a.ntotal+')</span>';
		s+='	</p></div>';
		s+='</a>';
		$('#deptlist').append(s);
	},
	showlist:function(a, cbo){
		var s='<a temp="user_'+a.id+'" onclick="im.openuinfo('+a.id+')" class="weui_media_box weui_media_appmsg">';
		s+='	<div class="weui_media_hd">';
		s+='		<img class="weui_media_appmsg_thumb" src="'+a.face+'">';
		s+='	</div>';
		s+='	<div class="weui_media_bd">';
		s+='		<h4 class="weui_media_title">'+a.name+'</h4>';
		s+='		<p class="weui_media_desc">'+a.deptname+'('+a.ranking+')</p>';
		s+='	</div>';
		s+='</a>';
		if(!cbo){
			$('#list').append(s);
		}else{
			$('#searchlist').append(s);
		}
	},
	showgroupall:function(){
		var i,len2=grouparr.length;
		$('#grouplist').html('');
		$('#groupstotal').html('('+len2+')');
		for(i=0;i<len2;i++)this.showgroup(grouparr[i], true);
	},
	showgroup:function(a, cbo){
		var s='';
		s+='<a class="weui_cell"  onclick="im.openguser(\'group\','+a.id+')">';
		s+=' 	<div class="weui_cell_hd"><img src="'+a.face+'" alt="" style="width:34px;margin-right:5px;display:block"></div>';
		s+=' 	<div class="weui_cell_bd weui_cell_primary"><p>'+a.name+'</p></div>';
		s+='</a>';
		$('#grouplist').append(s);
	},
	initsearch:function(){
		$('#search_input').keydown(function(){
			im.sousousou();
		});
		$('#search_input').keyup(function(){
			im.sousousou();
		});
	},
	searchuser:function(){
		$('#search_bar').addClass('weui_search_focusing');
		$('#search_input').focus();
	},
	blursou:function(){
		var val = $('#search_input').val();
		if(val==''){
			$('#search_bar').removeClass('weui_search_focusing');
			this.hitsoubo(false);
		}
	},
	searchcancel:function(){
		$('#search_input').val('').blur();
		this.blursou();
	},
	souclear:function(){
		$('#search_input').val('').focus();
	},
	sousousou:function(){
		clearTimeout(this.sousousoutime);
		this.sousousoutime=setTimeout('im.sousousous()',500);
	},
	hitsoubo:function(bo){
		if(!bo){
			$('#userdao').show();
			$('#deptlist').show();
			$('#list').show();
			$('#searchlist').hide();
		}else{
			$('#userdao').hide();
			$('#deptlist').hide();
			$('#list').hide();
			$('#searchlist').show().html('');
		}
	},
	sousousous:function(){
		var val = $('#search_input').val();
		if(val==''){
			this.hitsoubo(false);
			return;
		}
		this.hitsoubo(true);
		var i,a=userarr,len=a.length;
		for(i=0;i<len;i++){
			if(a[i].name.indexOf(val)>-1 || a[i].deptname.indexOf(val)>-1 || a[i].ranking.indexOf(val)>-1 || a[i].pingyin.indexOf(val)==0){
				this.showlist(a[i],true);
			}
		}
	},
	isgzh:0,
	showmyinfo:function(){
	
		js.ajaxbool=false;
		js.ajax('indexreim','showmyinfo', false,function(ret){
			js.setoption('deptallname',ret.deptallname);
			js.setoption('ranking',ret.ranking);
			adminface	= ret.face;
			js.setoption('adminface',adminface);
			js.setoption('admintoken',ret.admintoken);
			adminame 	= ret.name;
			js.setoption('adminame',adminame);
			js.setoption('adminid',ret.id);
			adminid 	= ret.id;

			get('myface').src=adminface;
			$('#myshow_id').html(adminid);
			$('#myname').html(adminame);
			$('#myshow_name').html(adminame+'('+ret.user+')');
			$('#myshow_deptname').html(ret.deptallname);
			$('#myshow_mobile').html(ret.mobile);
			$('#myshow_email').html(ret.email);
			// $('#myshow_qq').html(ret.qq);
			$('#myshow_ranking').html(ret.ranking);
			im.isgzh	= ret.isgzh;
			im.showcompanyinfo(ret.companyinfo);
		},'none');
	},
	changewxtx:function(o1){
		var tx = o1.checked ? '1' : '0';
		js.ajax('indexreim','changewxtx', {tx:tx},function(){

		},'none',false,false,'get');
	},
	tongbuface:function(){
		js.ajax('indexreim','tongbuface', false,function(ret){
			var fac = ret.face;
			if(fac){
				adminface = fac;
				js.setoption('adminface',fac);
				get('myface').src=adminface+'?'+Math.random()+'';
			}
			js.msg('success','同步成功');
		},'wait');
	},
	bangdwex:function(){
		if(!js.iswxbo()){
			js.wx.alert('请使用微信客户端访问才可以绑定');
			return;
		}
		if(this.isgzh==0){js.wx.alert('当前无法绑定');return;}
		js.wx.load('处理中...');
		js.location('?m=login&d=we&a=oauthto&state=bang');
	},
	changecomp:function(){
		js.location('?m=index&d=we&a=company');
	},
	//修改头像
	editface:function (){
		js.ajaxbool=false;
		js.ajax('indexreim','showmyinfo', false,function(ret){
			adminame 	= ret.name;
			adminid 	= ret.id;
			js.mobileupload('im.editfacechangback',{maxup:'1',thumbnail:'150x150','title':'修改['+adminame+']的头像',uptype:'image','params1':adminid,'urlparams':'noasyn:yes'});	
		},'none');
		
},
 editfacechangback:function(a,xid){
	var f = a[0];
	var nf= f.thumbpath+'?'+Math.random()+'';
	if(xid==adminid)get('myface').src=nf;
	if(get('faceviewabc_'+xid+''))get('faceviewabc_'+xid+'').src=nf;
	js.msg('wait','头像修改中...');
	var d = {fid:f.id,uid:xid};
	js.ajax('user','editfacenew',d,function(ret){
		 	js.msg('success','修改成功');
	},'none');

},
houtai:function(){
	var domain = document.domain;
	var url='http://'+domain+'?pc=1';
	js.location(url);
}
};

</script>
</head>


<body scroll="no" style="overflow:hidden">
<?php if($showheader==1){?>
<div>
	<div class="r-header">
		<div class="r-header-text" onclick="location.reload()" id="header_title">SesOffice</div>
		<!-- <span onclick="im.showmenu()" class="r-position-right r-header-btn"><i class="icon-plus"></i></span> -->
	
	</div>
	<div class="blank50"></div>
</div>
<?php }?>


<div id="mainbody" class="r-touch" style="height:350px;position:relative;">
	<!-- 消息 -->
	<div index="main" id="main_index0">
		<div id="home_silder"></div>
		<div id="home_yinglistdiv" style="margin-bottom:15px;display:none">
		<div class="agentp">办公</div>
		<div id="home_yinglist" style="background:white" class="weui_grids"></div>
		</div>
		<div  class="weui_panel"><div id="historylist"></div></div>
		<div id="historylist_tems" style="padding-top:50px;text-align:center;color:#cccccc"><span style="font-size:40px"><i class="icon-comment-alt"></i></span><br>暂无消息</div>
	</div>
<!-- 办公 -->
	<div index="main" style="display:none" id="main_index1"></div>
	<!-- 云盘 -->
	<div index="main" style="display:none;" id="main_index2"></div>
	<div index="main" style="display:none;" id="mainbody_show"></div>
<!-- 联系人 -->	
	<div index="main" style="background-color:white;display:none" id="main_index3">

		<div class="weui_search_bar" id="search_bar">
			<form onclick="im.searchuser()" class="weui_search_outer" onsubmit="im.sousousou();return false;">
				<div class="weui_search_inner">
					<i class="weui_icon_search"></i>
					<input type="search" onblur="im.blursou()" class="weui_search_input" id="search_input" placeholder="搜索联系人" >
					<a onclick="im.souclear()" class="weui_icon_clear"></a>
				</div>
				<label for="search_input" class="weui_search_text" id="search_text">
					<i class="weui_icon_search"></i>
					<span>搜索联系人</span>
				</label>
			</form>
			<a onclick="im.searchcancel()" style="color:#1389D3" class="weui_search_cancel">取消</a>
		</div>

		<div id="userlx" class="r-tab">
			<div id="userlx_0" onclick="im.changeuser(0)" class="r-tab-item active">联系人<span id="userstotal">(0)</span></div>
			<div id="userlx_1" onclick="im.changeuser(1)" class="r-tab-item">会话<span id="groupstotal">(0)</span></div>

		</div>

		<div id="userlistdiv" temp="user" style="margin-top:0">
			<div class="weui_daohang r-border-b" id="userdao">
			</div>
			<div class="weui_panel_bd">
				<div id="list" class="weui_panel weui_panel_access"></div>
				<div id="deptlist"></div>
				<div id="searchlist" class="weui_panel weui_panel_access"></div>
			</div>
		</div>
		<div class="weui_panel" temp="user" style="margin-top:0;display:none">
			<div class="weui_panel_bd r-border-t">
				<div class="weui_media_box weui_media_small_appmsg">
					<div id="grouplist" class="weui_cells weui_cells_access"></div>
				</div>
			</div>
		</div>
		<div class="weui_panel" temp="user" style="margin-top:0;display:none"><div id="showdept"></div></div>
	</div>
<!-- 我的 -->
	<div index="main" style="display:none"  id="main_index4">

		<div style="margin-top:5px" class="weui_panel weui_panel_access">
			<div class="weui_panel_bd">
				<a   class="weui_media_box weui_media_appmsg">
					<div class="weui_media_hd">
						<img class="weui_media_appmsg_thumb" id="myface" src="images/logo.png">
					</div>
					<div class="weui_media_bd" ">
						<h4 class="weui_media_title" id="myshow_name"></h4>
						<p style="font-size:14px;color:#888888"><label id="myshow_deptname"></label></p>
					</div>

					<div class="weui_media_bd" style="text-align: right;">
						
						<div style="width: 92px;float:right;text-align: center;">
							<p style="color: #fff;background-color: #EF4F4F;border-radius:12px;height: 26px;line-height: 26px;" onclick="im.houtai()">登录PC版</p>
							<p style="font-size: 12px;margin-top: 5px;">
								<?php
								if(2>1){
									echo '还剩90天到期';
								}
								?></p>


						</div>
					
						
					</div>
				</a>
			</div>
		</div>



		<div class="weui_cells weui_cells_access wode">
			<div class="weui_cell ">
				<div class="weui_cell_bd weui_cell_primary ">
					<p style="color:#888888">职位</p>
				</div>
				<span id="myshow_ranking" class="weui_cell_right "></span>
			</div>
			<div class="weui_cell ">
				<div class="weui_cell_bd weui_cell_primary ">
					<p style="color:#888888">用户Id</p>
				</div>
				<span id="myshow_id" class="weui_cell_right"></span>
			</div>
			<div class="weui_cell ">
				<div class="weui_cell_bd weui_cell_primary">
					<p style="color:#888888">Tel:</p>
				</div>
				<span id="myshow_mobile" class="weui_cell_right">15800000000</span>
			</div>
			<div class="weui_cell ">
				<div class="weui_cell_bd weui_cell_primary">
					<p style="color:#888888">Email:</p>
				</div>
				<span id="myshow_email" class="weui_cell_right">15800000000@qq.com</span>
			</div>
			<!-- <div class="weui_cell ">
				<div class="weui_cell_bd weui_cell_primary">
					<p style="color:#888888">QQ:</p>
				</div>
				<span id="myshow_qq" class="weui_cell_right">12345678</span>
			</div> -->
		</div>

		<div id="weixllq" class="weui_cells weui_cells_access wode">

			<!--
			<div onclick="im.bangdwex()" class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					绑定微信
				</div>
				<span class="weui_cell_ft">未绑定,点击绑定</span>
			</div>-->
			<?php if(ISMORECOM){?>
			<div onclick="im.changecomp()" class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					切换单位
				</div>
				<p style="color:#888888;font-size:14px" id="nowcompany_div"></p>
				<span class="weui_cell_ft"></span>
			</div>
			<?php }?>
			<div  onClick="im.editface()" class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					修改头像
				</div>
				<span class="weui_cell_ft"></span>
			</div>
			<div onclick="im.editpass()" class="weui_cell">
				<div class="weui_cell_bd weui_cell_primary">
					修改密码
				</div>
				<span class="weui_cell_ft"></span>
			</div>
		</div>

		<div class="weui_cells weui_cells_checkbox wode">
			<label class="weui_cell weui_check_label" for="wxtxchecked">
				<div class="weui_cell_hd">
					<input type="checkbox" disabled class="weui_check" id="wxtxchecked" checked="checked">
					<i class="weui_icon_checked"></i>
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<p>微信接收推送提醒</p>
				</div>
			</label>
		</div>
	<!-- 隐形加密 -->
	<div id="jiami" class="weui_cells weui_cells_access wode">
		<div onclick="im.jiami()" class="weui_cell">
			<div class="weui_cell_bd weui_cell_primary">
				隐形加密
			</div>
			<span class="weui_cell_ft"></span>
		</div>
	</div>

		<div class="weui_btn_area">
			<input class="weui_btn weui_btn_warn" style="width: 98px;border-radius: 20px;line-height:1.7;font-size: 17px;" type="button" onclick="im.loginout()" value="退出登录">
		</div>
		<div style="height:10px"></div>
	</div>
</div>




<div style="height:55px; overflow:hidden"></div>
<div id="footerdiv" style="height:55px;overflow:hidden;z-index:2" class="weui_tabbar">
	<a href="javascript:;" onclick="im.changetab(0)" class="weui_tabbar_item weui_bar_item_on">
		<span id="stotal_ss0" class="badge"></span>
		<div class="weui_tabbar_icon">
			<i class="icon-comment-alt"></i>
		</div>
		<p class="weui_tabbar_label">消息</p>
	</a>
	<a href="javascript:;" onclick="im.changetab(1)" class="weui_tabbar_item">
		<span id="stotal_ss1" class="badge"></span>
		<div class="weui_tabbar_icon">
			<i class="icon-th-large"></i>
		</div>
		<p class="weui_tabbar_label">办公</p>
	</a>
	<a href="javascript:;" onclick="im.changetab(2)" class="weui_tabbar_item">
		<span id="cloud" class="badge"></span>
		<div class="weui_tabbar_icon">
			<i class="icon-save"></i>
		</div>
		<p class="weui_tabbar_label">云盘</p>
	</a>
	<a href="javascript:;" onclick="im.changetab(3)" class="weui_tabbar_item">
		<div class="weui_tabbar_icon">
			<i class="icon-group"></i>
		</div>
		<p class="weui_tabbar_label">联系人</p>
	</a>
	<a href="javascript:;" onclick="im.changetab(4)" class="weui_tabbar_item">
		<div class="weui_tabbar_icon">
			<i class="icon-cog"></i>
		</div>
		<p class="weui_tabbar_label">我的</p>
	</a>
</div>
<script type="text/javascript" src="mode/plugin/jquery-rockdoupull.js"></script>
<script type="text/javascript" src="mode/plugin/jquery-rocksilder.js"></script>
<script type="text/javascript" src="web/res/js/jquery-changeuser.js"></script>
</body>
</html>